﻿using System.Collections.Generic;
using System.Text;

namespace Ex03.GarageLogic
{
    /// <summary>
    /// This class is for an Electric Powered Motorcycle
    /// Inherits from Electric Powered Vehicle
    /// </summary>
    public class ElectricPoweredMotorcycle : ElectricPoweredVehicle
    {
        private const float k_BatteryCapacityInHours = 2.4f;
        private static readonly Dictionary<string, string> sr_ElectricPoweredMotorcycleForm;

        private MotorcycleData m_Data;

        /// <summary>
        /// This is a static constructor that will initialize the Electric
        /// Powered Motorcycle
        /// </summary>
        static ElectricPoweredMotorcycle()
        {
            sr_ElectricPoweredMotorcycleForm = new Dictionary<string, string>(ElectricPoweredVehicleForm);
            foreach (KeyValuePair<string, string> keyValue in MotorcycleData.MotorcycleDataForm)
            {
                sr_ElectricPoweredMotorcycleForm.Add(keyValue.Key, keyValue.Value);
            }            
        }

        /// <summary>
        /// A constructor that will pass all input to its base
        /// </summary>
        /// <param name="i_PlateNumber">plate number needed by parent </param>
        /// <param name="i_NumberOfWheels">number of wheels needed by parent</param>
        /// <param name="i_WheelMaxAirPressure">wheel max air pressure needed by parent</param>
        public ElectricPoweredMotorcycle(string i_PlateNumber)
            : base(i_PlateNumber, MotorcycleData.k_NumberOfWheels, MotorcycleData.k_MaxAirPressureOfWheels)
        {
        }

        /// <summary>
        /// This is the main initialization function of this object
        /// This function will receive a form with all the data needed for the initialization
        /// </summary>
        /// <param name="i_CreationForm">A key value Dictionary where key is the name of the member 
        /// to initialize and value is the new value
        /// </param>        
        public override void Initialize(Dictionary<string, string> i_CreationForm)
        {
            base.Initialize(i_CreationForm);
            m_Data = new MotorcycleData(i_CreationForm);
        }

        /// <summary>
        /// A property to get the battery capacity in hours
        /// </summary>
        public override float BatteryCapacityInHours
        {
            get { return k_BatteryCapacityInHours; }
        }

        /// <summary>
        /// A method to get the form of the Electric Powered Car 
        /// </summary>
        public override Dictionary<string, string> GetForm()
        {
            return new Dictionary<string, string>(sr_ElectricPoweredMotorcycleForm);
        }

        /// <summary>
        /// Return a string representation object members as pair 
        /// members name and variable value
        /// </summary>
        /// <returns>string "varName + Vehicle.k_ToStirngPairDelimiter + varValue + Vehicle.sr_ToStirngEndOfPairDelimiter"</returns>
        public override string ToString()
        {
            StringBuilder stringBuilderResult = new StringBuilder();

            stringBuilderResult.Append(base.ToString());
            stringBuilderResult.Append(m_Data.ToString());

            return stringBuilderResult.ToString();
        }
    }
}
